package com.ruoyi.web.controller.organization;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.organization.domain.vo.BizConsultVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.organization.domain.BizConsult;
import com.ruoyi.organization.service.IBizConsultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 居民评议Controller
 * 
 * @author ruoyi
 * @date 2024-05-25
 */
@RestController
@RequestMapping("/organization/consult")
public class BizConsultController extends BaseController
{
    @Autowired
    private IBizConsultService bizConsultService;

    /**
     * 查询居民评议列表
     */
    @PreAuthorize("@ss.hasPermi('organization:consult:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizConsult bizConsult)
    {
        startPage();
        List<BizConsultVo> list = bizConsultService.selectBizConsultList(bizConsult);
        return getDataTable(list);
    }

    /**
     * 导出居民评议列表
     */
    @PreAuthorize("@ss.hasPermi('organization:consult:export')")
    @Log(title = "居民评议", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizConsult bizConsult)
    {
        List<BizConsultVo> list = bizConsultService.selectBizConsultList(bizConsult);
        ExcelUtil<BizConsultVo> util = new ExcelUtil<BizConsultVo>(BizConsultVo.class);
        util.exportExcel(response, list, "居民评议数据");
    }

    /**
     * 获取居民评议详细信息
     */
    @PreAuthorize("@ss.hasPermi('organization:consult:query')")
    @GetMapping(value = "/{consultId}")
    public AjaxResult getInfo(@PathVariable("consultId") String consultId)
    {
        return success(bizConsultService.selectBizConsultByConsultId(consultId));
    }

    /**
     * 新增居民评议
     */
    @PreAuthorize("@ss.hasPermi('organization:consult:add')")
    @Log(title = "居民评议", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizConsult bizConsult)
    {
        return toAjax(bizConsultService.insertBizConsult(bizConsult));
    }

    /**
     * 修改居民评议
     */
    @PreAuthorize("@ss.hasPermi('organization:consult:edit')")
    @Log(title = "居民评议", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizConsult bizConsult)
    {
        return toAjax(bizConsultService.updateBizConsult(bizConsult));
    }

    /**
     * 删除居民评议
     */
    @PreAuthorize("@ss.hasPermi('organization:consult:remove')")
    @Log(title = "居民评议", businessType = BusinessType.DELETE)
	@DeleteMapping("/{consultIds}")
    public AjaxResult remove(@PathVariable String[] consultIds)
    {
        return toAjax(bizConsultService.deleteBizConsultByConsultIds(consultIds));
    }
}
